package com.example.findmystuff;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class SearchDateActivity extends Activity {
	
	Button search, cancel;
	EditText criteria;
	/**
	 * This method is called when the activity is created
	 * @param savedInstanceState a bundle used to save the state that this instance of the activity is in.
	 */
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_search_date);
		
		search = (Button) findViewById(R.id.searchButton);
		cancel = (Button) findViewById(R.id.cancelButton);
		criteria = (EditText) findViewById(R.id.editText1);
		
		
		search.setOnClickListener(
        		new View.OnClickListener() {
					@Override
					public void onClick(View v) {
						// TODO Auto-generated method stub
						Intent i = new Intent(SearchDateActivity.this, ListItemsActivity.class);
						i.putExtra("filter",2);
						i.putExtra("search",criteria.getText().toString());
						startActivity(i);
					}
				});
		
        cancel.setOnClickListener(
        		new View.OnClickListener() {
					@Override
					public void onClick(View v) {
						// TODO Auto-generated method stub
						Intent i = new Intent(SearchDateActivity.this, SearchActivity.class);
						startActivity(i);
					}
				});
	}
	/**
	 * Initializes the contents of the Activity's standard options menu.
	 * @param menu the standard options menu
	 */
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_search_date, menu);
		return true;
	}

}
